<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%@ page import="hk.hku.hooku.db.*"%>
<%@ page import="hk.hku.hooku.pojo.*" %>
<%@ page import="hk.hku.hooku.util.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.Map.*" %>
<%@ page import="java.sql.Timestamp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="js/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="js/userInit.js" ></script>
<%
	String username=(String)session.getAttribute("loginUser");
	if(username==null||username==""){
		response.sendRedirect("login.jsp");
	}
	User user=UserDB.getFullUserByGmail(username);
%>

<title>Hooku Event List</title>


<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/user.css" />

</head>

<body>

<!--header -->
<div id="header-wrap"><div id="header">
	<h1 id="logo-text"><a href="eventCreate.jsp" title="">Hooku</a></h1>
	<p id="slogan">To Make the Easiest Arragements </p>

	

<!--/header-->
</div></div>
	
<!-- content-outer -->
<div id="content-wrap" class="clear" >

	<!-- content -->
   <div id="content">

   	<!-- main -->
	   <div id="main">

     
            <div class="post-bottom-section">

<div class="right">
				<p><h3>History Created Arrangements</h3></p>
            	<form  >

               
				<div class="no-border" id="voteTable">
				<%
				ArrayList<Event> events=user.getProposeHistory();
				if(events.size()==0){%>
					<h3>No history arrangements</h3>
				<%}else{%>
					<table id="eventList">
						<thead>
							<!-- Date slots -->
							<tr>
								<th id="titleHead">Title</th>
								<th id="timeHead">Create Time</th>
							</tr>
						</thead>
						<tbody>
							<%
							for(Event event:events){
								String url=event.getUrl();
								String title=event.getTitle();
								Date date=TimeUtil.toDate(event.getCreateTime());
								String month=TimeUtil.toShortMonth(date);
								int day=date.getDate();
								int year=date.getYear()+1990;
								String createTime=String.format("%s %d,%d",month,day,year);%>
								<tr>
									<td><a href="event.jsp?url=<%=url%>"/><%=title %></a></td>
									<td><%=createTime %></td>
								</tr>
							<%}
							%>
						</tbody>
					</table>
				<%}
				%>
				</div>
			
			
			 
			<p class="no-border" id="messageDiv" hidden></p>
			<p class="no-border" id="errorMsgDiv" hidden></p>
               </form>

            </div>
            <div class="right">		
			</p>
			
			<p class="no-border" id="messageDiv" hidden></p>
			<p class="no-border" id="errorMsgDiv" hidden></p>
			
            </div>

         </div>

        <!-- /main -->
		</div>

      <!-- sidebar -->
		<div id="sidebar">
		<h3>Loged in User</h3>
				<p>
					<input id="userMail" type="text" value="<%=user.getGmail() %>" id="url" disabled/>
				</p>
			<div class="sidemenu">
				<p>
					<input type="button" class="button" id="createButton" value="Create New Arrangement"/>
				</p> 
				<p>
					<input type="button" class="button" id="importButton" value="Import Contact From Gmail"/>
				</p>
				<form id="importForm" hidden>
					<div id="importDiv">
					<p class="no-border"><input type="email" id="gmailAddress" value="Gmail Address"/></p>
					<p class="no-border"><input type="password" id="gmailPassword"/></p>
					<p class="no-border"><input type="button" class="button" id="importButton2" value="Import"/></p>
					<p class="no-border" id="importMessageDiv" hidden></p>
					<p class="no-border" id="importErrorMsgDiv" hidden></p>
					</div> 
				</form>       

			</div>
			<div class="about-me">

         	<h3>About Us</h3>
		      <p>
		      <a href="http://www.cs.hku.hk/~fliang"><img src="images/hku.png" width="40" height="40" alt="firefox" class="float-left" /></a>
            We are an innovative and enthusiastic team from the CS department of The University of Hong Kong.   <a href="http://www.cs.hku.hk/~fliang">Learn more...</a>
				</p>

         </div>

      <!-- /sidebar -->
		</div>

    <!-- content -->
	</div>

<!-- /content-out -->
</div>

<!-- footer-bottom -->
<div id="footer-bottom">

	<p class="bottom-left">
		&copy; 2013 <strong>Copyright Info</strong>&nbsp; &nbsp; &nbsp;
		<a href="http://www.cs.hku.hk/~fliang" title="homepage">Hooku</a> from <a href="http://www.cs.hku.hk/~fliang">HKU</a>
	</p>

	<p class="bottom-right">
		<a href="index.html">Home</a> |
      <strong><a href="#top">Back to Top</a></strong>
   </p>

<!-- /footer-bottom-->
</div>

</body>
</html>
